package io;

import java.io.Serializable;

public class Person implements Serializable {

    // serialVersionUID防止类字段改变时反序列化错误，已经改变的字段会忽略赋值
    private static final long serialVersionUID = -1010230383063118720L;
    private String name;
    private int age;
//    private static int age = 18; // static关键字修饰的字段也会忽略序列化
//    private transient int age; // transient关键字的作用就是忽略该字段的序列化

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
